import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NativePageTransitions, NativeTransitionOptions } from '@ionic-native/native-page-transitions';
import { AlertService } from '../../provider/alert.service';

@Component({
  selector: 'page-find',
  templateUrl: 'find.html'
})
export class FindPage {

  rootPage: any;
  items: Array<{ title: string, page: any, icon: string, color: string }>;
  rowlens: any;

  constructor(public navCtrl: NavController, private nativePageTransitions: NativePageTransitions,
              public alertService: AlertService) {
    this.rootPage = 'FindPage';

  }

  ionViewDidLoad() {
    this.items = [
      {
        title: 'Pinterest Masonry Cards',
        page: 'MasonryCardsPage',
        icon: 'ios-analytics-outline',
        color: '#d26363'
      },
      {
        title: 'Photo Swipe Demo',
        page: 'PhotoswipeDemoPage',
        icon: 'ios-images-outline',
        color: '#8d72dc'        
      },
      {
        title: 'Photo Swipe Demo',
        page: 'PhotoswipeDemoPage',
        icon: 'ios-settings-outline',
        color: '#8d72dc'        
      },      
      {
        title: '暂无',
        page: 'null',
        icon: 'ios-aperture-outline',
        color: '#97d263'        
      }
    ];

    //let arrayTemp = Array(Math.ceil(this.items.length / 3));

    //this.rowlens = arrayTemp.fill("").map((x,i)=>i);
  }


  itemTapped(event, item) {
    if (item.page == "null") {
      this.alertService.presentAlert('提示信息', '该功能暂无.');
      return;
    }

    let options: NativeTransitionOptions = {
      direction: 'left',
      duration: 400,
      slowdownfactor: -1,
      iosdelay: 50
     };
 
    this.nativePageTransitions.slide(options);    

    if (item.page) {
      this.navCtrl.push(item.page);
    } else {
      this.navCtrl.push(item);
    }
    
  }

}
